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 @@ -861,6 +861,55 @@ class LND {
861
861
return err ( e ) ;
862
862
}
863
863
}
864
+
865
+ /**
866
+ * LND SendCoins
867
+ * Send onchain transaction to a single output
868
+ * @param address
869
+ * @param amount
870
+ * @param targetConf
871
+ * @param feeRate
872
+ * @param sendAll
873
+ * @param label
874
+ * @returns {Promise<Ok<lnrpc.SendCoinsResponse> | Err<unknown>> }
875
+ */
876
+ async sendCoins (
877
+ address : string ,
878
+ amount : number ,
879
+ targetConf ?: number ,
880
+ feeRate ?: number ,
881
+ sendAll ?: boolean ,
882
+ label ?: string
883
+ ) : Promise < Result < lnrpc . SendCoinsResponse > > {
884
+ try {
885
+ const message = lnrpc . SendCoinsRequest . create ( ) ;
886
+
887
+ message . addr = address ;
888
+ message . amount = amount ;
889
+
890
+ if ( targetConf ) {
891
+ message . targetConf = targetConf ;
892
+ }
893
+ if ( feeRate ) {
894
+ message . satPerVbyte = feeRate ;
895
+ }
896
+ if ( sendAll ) {
897
+ message . sendAll = sendAll ;
898
+ }
899
+ if ( label ) {
900
+ message . label = label ;
901
+ }
902
+
903
+ const serializedResponse = await this . grpc . sendCommand (
904
+ EGrpcSyncMethods . SendCoins ,
905
+ lnrpc . SendCoinsRequest . encode ( message ) . finish ( )
906
+ ) ;
907
+
908
+ return ok ( lnrpc . SendCoinsResponse . decode ( serializedResponse ) ) ;
909
+ } catch ( e ) {
910
+ return err ( e ) ;
911
+ }
912
+ }
864
913
}
865
914
866
915
export default new LND ( ) ;
You can’t perform that action at this time.
0 commit comments