This repository was archived by the owner on Oct 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -898,6 +898,55 @@ class LND {
898
898
return err ( e ) ;
899
899
}
900
900
}
901
+
902
+ /**
903
+ * LND SendCoins
904
+ * Send onchain transaction to a single output
905
+ * @param address
906
+ * @param amount
907
+ * @param targetConf
908
+ * @param feeRate
909
+ * @param sendAll
910
+ * @param label
911
+ * @returns {Promise<Ok<lnrpc.SendCoinsResponse> | Err<unknown>> }
912
+ */
913
+ async sendCoins (
914
+ address : string ,
915
+ amount : number ,
916
+ targetConf ?: number ,
917
+ feeRate ?: number ,
918
+ sendAll ?: boolean ,
919
+ label ?: string
920
+ ) : Promise < Result < lnrpc . SendCoinsResponse > > {
921
+ try {
922
+ const message = lnrpc . SendCoinsRequest . create ( ) ;
923
+
924
+ message . addr = address ;
925
+ message . amount = amount ;
926
+
927
+ if ( targetConf ) {
928
+ message . targetConf = targetConf ;
929
+ }
930
+ if ( feeRate ) {
931
+ message . satPerVbyte = feeRate ;
932
+ }
933
+ if ( sendAll ) {
934
+ message . sendAll = sendAll ;
935
+ }
936
+ if ( label ) {
937
+ message . label = label ;
938
+ }
939
+
940
+ const serializedResponse = await this . grpc . sendCommand (
941
+ EGrpcSyncMethods . SendCoins ,
942
+ lnrpc . SendCoinsRequest . encode ( message ) . finish ( )
943
+ ) ;
944
+
945
+ return ok ( lnrpc . SendCoinsResponse . decode ( serializedResponse ) ) ;
946
+ } catch ( e ) {
947
+ return err ( e ) ;
948
+ }
949
+ }
901
950
}
902
951
903
952
export default new LND ( ) ;
You can’t perform that action at this time.
0 commit comments