@@ -1662,6 +1662,12 @@ func (r *rpcServer) NewAddr(ctx context.Context,
16621662 err )
16631663 }
16641664
1665+ // Sanity check early to ensure that the asset is known.
1666+ _ , err = r .cfg .AddrBook .QueryAssetInfo (ctx , specifier )
1667+ if err != nil {
1668+ return nil , fmt .Errorf ("unable to find asset or group: %w" , err )
1669+ }
1670+
16651671 err = r .checkBalanceOverflow (ctx , assetID , groupKey , req .Amt )
16661672 if err != nil {
16671673 return nil , err
@@ -1698,40 +1704,49 @@ func (r *rpcServer) NewAddr(ctx context.Context,
16981704 "courier=%v, addr_version=%v, asset_version=%v" , & specifier ,
16991705 req .Amt , courierAddr , addrVersion , assetVersion )
17001706
1701- // Addresses with version 2 must use the new authmailbox proof courier
1707+ // Addresses with version 2 must use the new auth mailbox proof courier
17021708 // type.
1703- protocol := courierAddr .Scheme
17041709 switch {
17051710 case addrVersion == address .V2 &&
1706- protocol == proof .UniverseRpcCourierType :
1711+ courierAddr . Scheme == proof .UniverseRpcCourierType :
17071712
17081713 // We assume that any proof courier running an RPC universe
17091714 // server will upgrade soon to support the new auth mailbox
17101715 // courier type, so we bump the protocol/scheme to the combined
17111716 // one.
17121717 courierAddr .Scheme = proof .AuthMailboxUniRpcCourierType
17131718
1714- // Let's make sure the proof courier actually supports the
1715- // auth mailbox courier type.
1716- err := proof .CheckUniverseRpcCourierConnection (
1717- ctx , proofCourierCheckTimeout , courierAddr ,
1718- )
1719- if err != nil {
1720- return nil , err
1721- }
1722-
17231719 case addrVersion == address .V2 &&
1724- protocol == proof .AuthMailboxUniRpcCourierType :
1720+ courierAddr . Scheme == proof .AuthMailboxUniRpcCourierType :
17251721
17261722 // Great, nothing to do here, this is the courier type we want.
17271723
1728- case addrVersion == address .V2 && protocol == proof .HashmailCourierType :
1724+ case addrVersion == address .V2 &&
1725+ courierAddr .Scheme == proof .HashmailCourierType :
1726+
17291727 return nil , fmt .Errorf ("%w: address version %d must use the " +
17301728 "'%s' proof courier type" ,
17311729 address .ErrInvalidProofCourierAddr , addrVersion ,
17321730 proof .AuthMailboxUniRpcCourierType )
17331731 }
17341732
1733+ // If the courier is an (auth mailbox) universe RPC type we will check
1734+ // that we can connect to it.
1735+ connCheckScheme := courierAddr .Scheme == proof .UniverseRpcCourierType ||
1736+ courierAddr .Scheme == proof .AuthMailboxUniRpcCourierType
1737+ if ! req .SkipProofCourierConnCheck && connCheckScheme {
1738+ rpcsLog .DebugS (ctx , "Checking connection to universe server " +
1739+ "RPC" , "courier_addr" , courierAddr .String ())
1740+
1741+ err := proof .CheckUniverseRpcCourierConnection (
1742+ ctx , proofCourierCheckTimeout , courierAddr ,
1743+ )
1744+ if err != nil {
1745+ return nil , fmt .Errorf ("connection check failed for " +
1746+ "universe server RPC proof courier: %w" , err )
1747+ }
1748+ }
1749+
17351750 var addr * address.AddrWithKeyInfo
17361751 switch {
17371752 // No key was specified, we'll let the address book derive them.
0 commit comments