lightningdevkit
Version:
Lightning Development Kit
72 lines • 2.74 kB
JavaScript
import { LSPS0ListProtocolsRequest } from '../structs/LSPS0ListProtocolsRequest.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* An bLIP-50 / LSPS0 protocol request.
*
* Please refer to the [bLIP-50 / LSPS0
* specification](https://github.com/lightning/blips/blob/master/blip-0050.md#lsps-specification-support-query)
* for more information.
*/
export class LSPS0Request extends CommonBase {
constructor(_dummy, ptr) { super(ptr, bindings.LSPS0Request_free); }
/* @internal */
static constr_from_ptr(ptr) {
const raw_ty = bindings.LDKLSPS0Request_ty_from_ptr(ptr);
switch (raw_ty) {
case 0: return new LSPS0Request_ListProtocols(ptr);
default:
throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
}
}
clone_ptr() {
const ret = bindings.LSPS0Request_clone_ptr(this.ptr);
return ret;
}
/**
* Creates a copy of the LSPS0Request
*/
clone() {
const ret = bindings.LSPS0Request_clone(this.ptr);
const ret_hu_conv = LSPS0Request.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, this);
return ret_hu_conv;
}
/**
* Utility method to constructs a new ListProtocols-variant LSPS0Request
*/
static constructor_list_protocols(a) {
const ret = bindings.LSPS0Request_list_protocols(CommonBase.get_ptr_of(a));
const ret_hu_conv = LSPS0Request.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
/**
* Checks if two LSPS0Requests contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
*/
eq(b) {
const ret = bindings.LSPS0Request_eq(this.ptr, CommonBase.get_ptr_of(b));
return ret;
}
/**
* Returns the method name associated with the given request variant.
*/
method() {
const ret = bindings.LSPS0Request_method(this.ptr);
const ret_conv = bindings.decodeString(ret);
return ret_conv;
}
}
/** A LSPS0Request of type ListProtocols */
export class LSPS0Request_ListProtocols extends LSPS0Request {
/* @internal */
constructor(ptr) {
super(null, ptr);
const list_protocols = bindings.LDKLSPS0Request_ListProtocols_get_list_protocols(ptr);
const list_protocols_hu_conv = new LSPS0ListProtocolsRequest(null, list_protocols);
CommonBase.add_ref_from(list_protocols_hu_conv, this);
this.list_protocols = list_protocols_hu_conv;
}
}
//# sourceMappingURL=LSPS0Request.mjs.map