Exemplo n.º 1
0
 /// <summary>
 /// Sends coins to the given address, via the given <see cref="Peer"/>.
 /// Change is returned to the first key in the wallet.
 /// </summary>
 /// <param name="peer">The peer to send via.</param>
 /// <param name="to">Which address to send coins to.</param>
 /// <param name="nanocoins">How many nanocoins to send. You can use Utils.ToNanoCoins() to calculate this.</param>
 /// <returns>The <see cref="Transaction"/> that was created or null if there was insufficient balance to send the coins.</returns>
 /// <exception cref="IOException">If there was a problem broadcasting the transaction.</exception>
 public Transaction SendCoins(Peer peer, Address to, ulong nanocoins)
 {
     lock (this)
     {
         var tx = CreateSend(to, nanocoins);
         if (tx == null) // Not enough money! :-(
             return null;
         peer.BroadcastTransaction(tx);
         ConfirmSend(tx);
         return tx;
     }
 }